// index.js
// 获取应用实例
const app = getApp()
var myData = require('../../utils/data.js');
Page({
  data: {
    //轮播图配置
    autoplay: true,
    interval: 3000,
    duration: 1200,
    active: 0,
    advertArr: [],//myData.getAdvertImg()
    shop1:[],
    shop2:[],
    shop3:[]
  },
  onLoad:function() {
    let that = this;
    myData.getData('http://localhost:8080/web/picture/v1/findAll').then(function(res){
      var lbArrImg = []
      if(res.code == 200){
        let lbList = res.data
         lbArrImg = new Array()
        for(var i = 0;i<lbList.length;i++){
          lbArrImg.push("http://localhost:8080"+lbList[i].picUrl)
        }
      }
      that.setData({
        advertArr : lbArrImg
      })
    });
    myData.getData('http://localhost:8080/web/shop/v1/findAllShop').then(function(res){
      var shopinfo = []
      if(res.code == 200){
        let shoplist = res.data
         shopinfo = new Array()
        for(var i = 0;i<shoplist.length;i++){
          shopinfo.push(shoplist[i])
        }
      }
      var shoparr1 = [];
      var shoparr2 = [];
      var shoparr3 = [];
      for(var i = 0;i<shopinfo.length;i++){
        if(shopinfo[i].shopType === "st1"){
          shoparr1.push(shopinfo[i])
        }else if(shopinfo[i].shopType === "st2"){
          shoparr2.push(shopinfo[i])
        }else{
          shoparr3.push(shopinfo[i])
        }
      }
      that.setData({
        shop1 : shoparr1,
        shop2 : shoparr2,
        shop3 : shoparr3
      })
    })
  },
  
  // 店铺卡片跳转到店铺内
  navgetDetall:function(e){
    // console.log(e.currentTarget.dataset);
    wx.navigateTo({
      url: '../shop/shop?shopId=' + e.currentTarget.dataset.id + '&shopName=' + e.currentTarget.dataset.shopname + '&shopUrl=' + e.currentTarget.dataset.urlpath + '&shopType=' + e.currentTarget.dataset.shoptype,
    })
  }
})
